package com.honey.feature.properties;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.util.regex.Pattern;

class PropertiesContent {
	private Reader reader;
	
	private static final Pattern regex = Pattern.compile("\\s") ;
	
	public PropertiesContent(Reader reader ){
		this.reader = reader ;
	}
	
	public  final String getContent() throws IOException{
		StringBuilder answer = new StringBuilder();
		BufferedReader bufferedReader = null;
		if( reader instanceof BufferedReader  ){
			bufferedReader = (BufferedReader) reader;
		}else{
			bufferedReader =new BufferedReader(reader);
		}
		String line = null;
		while( (line = bufferedReader.readLine()) != null){
			line = line.trim();
			if( line.length() >0 ){
				if(line.charAt(0)!='#'){
					answer.append(line);
				}
			}
		}
		
		return regex.matcher(answer.toString()).replaceAll("");
	}
}
